
#ifndef __OSEL_PORT_H
#define __OSEL_PORT_H

#include <iocc2530.h>

#define OSEL_INT_LOCK()                          (EA = 0)
#define OSEL_INT_UNLOCK()                        (EA = 1)
#define CODE                                     __code                  

#define OSEL_ISR_ENTRY() do                         	\
    {                                                   \
        osel_int_nest ++;                               \
    } while (0)

#define OSEL_ISR_EXIT() do                          	\
    {                                                   \
        OSEL_INT_LOCK();                                \
        if(--osel_int_nest == 0){                       \
            osel_schedule();                            \
        }                                               \
        OSEL_INT_UNLOCK();                              \
    } while (0)

#define OSEL_POST_EXIT()    do{                     	\
        OSEL_INT_LOCK();                                \
        if(osel_int_nest == 0){                         \
            osel_schedule();                            \
        }                                               \
        OSEL_INT_UNLOCK();                              \
    }while(0)

/************************************************************/
typedef unsigned char                           osel_bool_t;
typedef unsigned char                           osel_uint8_t;
typedef signed   char                           osel_int8_t;
typedef unsigned int                            osel_uint16_t;
typedef signed   int                            osel_int16_t;
typedef unsigned long                           osel_uint32_t;
typedef signed long                             osel_int32_t;

enum {OSEL_FALSE,OSEL_TRUE};
extern osel_uint8_t osel_int_nest;

void osel_start(void);

void osel_exit(void);

void osel_eoi(void);

#endif
